CMAKE_MINIMUM_REQUIRED(VERSION 2.6)

PROJECT(dvbsnoop)

SET(PACKAGE_VERSION "1.4.56")
SET(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
SET(LIBRARIES m)

SET(LINUX_DVB_DMX_PATH "linux/dvb/dmx.h")
FIND_FILE(LINUX_DVB_DMX ${LINUX_DVB_DMX_PATH}) 
IF (${LINUX_DVB_DMX} STREQUAL "LINUX_DVB_DMX-NOTFOUND")
  MESSAGE(FATAL_ERROR "Could NOT find LINUX DVB API")
ELSE()
  ADD_DEFINITIONS(-DHAVE_LINUX_DVB_DMX_H=1)
ENDIF()

FILE(GLOB_RECURSE SOURCES ${SOURCE_DIR}/*.c)

INCLUDE_DIRECTORIES(${SOURCE_DIR})

ADD_DEFINITIONS(
  -D_FILE_OFFSET_BITS=64
  -D_LARGEFILE_SOURCE
  -D_LARGEFILE64_SOURCE
  -DPACKAGE_VERSION="${PACKAGE_VERSION}"
)

ADD_EXECUTABLE(${CMAKE_PROJECT_NAME} ${SOURCES})

TARGET_LINK_LIBRARIES(${CMAKE_PROJECT_NAME} ${LIBRARIES})
